Skip to main content

Push notifications

Instructions for sending push notifications from iRidi Server to iOS and Android devices with the i3 pro application

You can send push notifications to i3 pro panels from external systems; in that case, you must use a push key instead of the notification group identifier: External push notifications.

How does it work?​

iRidi Server can notify the user of any event it detects in the automation system. One notification method is sending a push notification to the user's smartphones and tablets on which the application is installed. The application may be closed; only an Internet connection is required. Without it, the recipient will not receive the push notification.

iRidi Server sends a "notify control panels" command to the iRidi Mobile website. The website forwards this command to Apple's or Google's proprietary services (depending on the control panel OS), and those services send notifications to the smartphones and tablets of users at the automation site.

HowPushWorks.png

To determine which smartphones and tablets should receive notifications, the iRidi Mobile website must see them in the list of active control panels.

iRidi Server sends notifications to logical device groups, rather than to each device individually. Groups can be configured in an iRidi Cloud object on the "Users and Panels" tab. See below for details.

Important
  • A push notification cannot be sent without iRidi Server.
  • If the control panel is not connected to the Internet, the push notification will not arrive.
  • Push notifications sometimes fail to reach the recipient. Always provide a backup channel for important messages, such as SMS. This is because Apple's and Google's proprietary services do not monitor push notification delivery.

Configuring push notification sending and handling​

Any iRidi Server event can be used to send a push notification:

  • A user-initiated command from a control panel or the server web interface;
  • A change in the state of automation system equipment;
  • A change in the date, time, or other environment parameters not directly associated with equipment or user actions.

A push notification can only be sent from iRidi Server to a smartphone or tablet with the application. A special command for sending notifications is configured in the server project's JavaScript editor. We will examine ways to call this command for different iRidi Server events:

  1. Create a new iRidi Server project in iRidi Studio (File > New > New Server Project...).

  2. Add variables to the server project whose changes should trigger notifications:

Push1.png

  • To send notifications when a button is pressed on the control panel, add a virtual command to the server project: Virtual > (+) > Add command. We will change the variable state from the control panel and use the change as a signal to send a notification;
  • To send notifications when the automation system changes, configure drivers for the system equipment in the project. We will use driver feedback changes as signals to send notifications;
  • To send notifications when the date and time change (or other system data changes), simply access the system parameters; no additional channels need to be created.
  1. Open the JS editor from the iRidi Studio toolbar. Create a new script file using (+) > New script and configure notification sending for different events in it. We will examine three options:

3.1. Send a notification from the control panel or server web interface.

watch the video

Sending a notification in this case uses a script:


//********** send push when User press a button in i3 pro **********

function push_from_i3(type, name, value)
{
IR.SendPush(value, "info", 1); // send notification (text of notification, hiden data, group of panels)
}

Push2.png

For the script to work, assign the function created in the script

push_from_i3

to the server's virtual command as a modifier. To do this, select the server's virtual command (we created "Push from Panel" in the example), open its Script Modifier property, and select the function

push_from_i3

Push3.png

Now any string written to "Push from Panel" is converted into a push notification and sent by the server to the control panels.

3.2. Send a notification when the driver state changes.

Sending a notification in this case uses a script:


//********** send push when Feedback of driver changes **********

var driver = IR.GetDevice("KNX"); // driver name

IR.AddListener(IR.EVENT_TAG_CHANGE, driver, function(name,value)
{
if (name == "Address 1" && value == 1) // if the KNX feedback "Address 1" changed to 1
{
IR.SendPush("Back door opened!", "show backdoor camera", 1); // text of notification, hiden data, group of panels
}
});

Push4.png

For the script to work, the "Address 1" feedback channel of the "KNX" driver must receive the value 1. No additional user action is required; the notification is sent automatically.

3.3. Send a notification when the selected date arrives.

Sending a notification in this case uses a script:


//********** send push when it is some Date & Time **********

IR.SetGlobalListener(IR.EVENT_GLOBAL_TAG_CHANGE, function (name, value)
{
// conditions:
if (IR.GetVariable("System.Date.MM_DD") == "03/14" && IR.GetVariable("System.Time.Hour") == 10 && IR.GetVariable("System.Time.Minutes") == 0)
{
IR.SendPush("Happy Birthday Mike!", "notification", 1); // text of notification, hiden data, group of panels
}
});

IR.SubscribeTagChange("System.Time.Minutes"); // subscribe on minutes to check condition each minute

Push5.png

The script runs every minute and checks whether the specified date and time have arrived. Changes to operating system parameters are handled by a global listener and subscription. The notification is sent when the conditions are met: the month/day and time match the selected notification time.

  1. Create a Panel Project: right-click the server project > Create Panel Project. In the created project, find the iRidi Server driver and specify the IP address (Host) of the device on which you plan to run iRidi Server; otherwise, the control panel will not be able to connect to it. No special settings are needed to receive notifications while the application is closed or minimized, but we will configure additional notification handling options (this is optional):

4.1. Configure push notification handling by the open application (RECOMMENDED )

Important

If you do not add a push notification handler to the Panel Project, you will not be able to tell that a notification arrived while the application is open.

By default, no push notification popup or sound appears if the application is already running and open on the control panel. However, server events may also need to be handled while the application is open. Therefore, to handle push notifications in the open application, add a script to the Panel Project (*.irpz):


//********** Play sound and display text when notification received by the opened app **********

IR.AddListener(IR.EVENT_RECIEVE_PUSH_NOTIFY, 0, function(text, data, group)
{
IR.PlaySound('Alerting.wav',0,50); // play sound

IR.GetPage("Page 1").GetItem("text").Text = text; // display text of notification
IR.GetPage("Page 1").GetItem("data").Text = data; // display hiden data that can be used in JS
});

Push6.png

In this example, when a push notification is received, the application plays a sound and writes the notification data to graphical items in the project.

4.2. For section 3.1 only. Configure notification sending when a button is pressed in the application

Applicable only if the server project contains the script from example 3.1, "Send a notification from the control panel or server web interface."

For user actions to trigger the notification sending implemented in the 1st server script example, control a virtual server variable from the control panel. This configuration is not directly related to push notification operation; here we only write a string to a virtual server variable. The server processes the string and converts it into a push notification for all control panels.

Create a graphical item, a button (Button) or input field (Editbox), that will send your notification text to the server. Find the "Push from Panel" command in the "iRidi Server" driver and drag it to the graphical item. In the command assignment dialog, select Send to command: Value from object and, in the value field, the .Text property of the button (or input field). Also assign the Show Keyboard command to the input field so that pressing it lets you enter data using the mobile device keyboard.

Push7.png Push8.png

  1. Save the server project and Panel Project and upload them to iRidi Cloud. Both projects must belong to the same cloud object.
Important

Push notifications arrive only on devices whose projects were downloaded from iRidi Cloud (not from Transfer).

  1. Create a Trial or commercial license for the object.

  2. Follow (activation, step 4) to invite an end user to the object, or use your alternative email address.

Important

A control panel signed in as an integrator cannot receive notifications because integrator devices are not included in the notification recipient list! To check whether notifications work, sign in to the application with an end user account.

  1. Configure Push Groups to organize users into groups. In the example, we configured messages to be sent to group 1, so we will create group 1 in the cloud:

AttachPushGroupX3.png

  1. Invite an end user to the project. In "Users and Panels", click "Push groups" to configure the groups that will include the invited user.

  2. Create group 1 (for our example) and give it any name.

  3. The group is now assigned to the user, who will receive notifications sent to the group.

  4. Sign in to the application on your iOS or Android device as an end user (activation, step 5.1) and download the project with notification handling. Remember that the integrator account cannot be used to test push notifications!.

  5. Sign in (activation, step 5.2) to the server as an integrator and download the project with notification handling.

Tip

If you configured the script from section 3.1, you can send a notification with arbitrary text through the server's web interface: open the "Channels&Feedback" tab, select the "Push from Panel" command, and enter the text to send. The server will generate a notification that will appear on your iOS or Android device.

  1. Everything is ready. Your mobile device will receive a notification from the server when any configured event occurs. Send notifications from the control panel or server web interface, or use notifications to monitor equipment state changes and date/time events.
Important

While the application is open and in the foreground on the control panel, no notification popup or sound appears. These must be configured separately for the active application; see section 4.2 .